package com.lm.paymentadmin.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author: liu2dog
 * @Date: 2020/12/21 10:00
 */
@Mapper
public interface TestMapper {
    /**
     * 更新库存(并发下此sql原子性)
     * @return int
     */
    @Update("update t_test set reserve = reserve + 1 where reserve > 0")
    public int updateReserve();

    /**
     * 查看库存
     * @return int
     */
    @Select("select reserve from t_test")
    public int queryReserve();

    /**
     * 更新库存
     * @param num
     * @return int
     */
    @Update("update t_test set reserve = #{num}")
    public int updateReserve1(int num);


    @Update("insert into t_test1(`text`) values('11111')")
    public int testSeata();
}
